package org.springblade.modules.repair.controller;

import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.AllArgsConstructor;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.repair.entity.MaintainCheckErrorLog;
import org.springblade.modules.repair.service.MaintainCheckErrorLogService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Date 10:01 2024/7/19
 * @Description {
 *   保养工单无法作业异常登记
 * }
 * @Author lsay
 **/
@AllArgsConstructor
@RestController
@RequestMapping("/check/error/log")
public class MaintainCheckErrorLogController {

	private final MaintainCheckErrorLogService checkErrorLogService;

	@GetMapping("/list")
	public R<List<MaintainCheckErrorLog>> list(Long planId){
		return R.data(checkErrorLogService.listByPlan(planId));
	}

	@PostMapping("/submit")
	public R<Boolean> submit(@RequestBody MaintainCheckErrorLog checkErrorLog){
		checkErrorLog.setCreateTime(DateUtil.date());
		return R.data(checkErrorLogService.saveOrUpdate(checkErrorLog));
	}

	@DeleteMapping("/remove")
	public R<Boolean> remove(String ids){
		return R.data(checkErrorLogService.removeByIds(Func.toLongList(ids)));
	}

}
